package com.ishansong.gis.tool;

import com.mongodb.Block;
import org.bson.BsonDocument;

/**
 * Created by danqiang on 2017/7/6.
 * read
 */
class PerfRead implements MTProcessor.Processor {

    private Commander.ArgsHolder commanderArgsHolder;

    PerfRead(Commander.ArgsHolder commanderArgsHolder) {
        this.commanderArgsHolder = commanderArgsHolder;
    }

    public void process(Mongo newMongo, BsonDocument bsonDocument) {
        newMongo.switchCollection(getNewDbName(), getNewCollectionName());
        newMongo.find(100, new Block<BsonDocument>() {
            @Override
            public void apply(BsonDocument bsonDocument) {
                System.out.println(bsonDocument.toJson());
            }
        });
    }

    @Override
    public String getOldDbName() {
        return "ss_location";
    }

    @Override
    public String getNewDbName() {
        return "ss_location";
    }

    @Override
    public String getOldCollectionName() {
        return "order_location_info_";
    }

    @Override
    public String getNewCollectionName() {
        return "order_location_info";
    }

    @Override
    public String toString() {
        return commanderArgsHolder.toString();
    }

}
